home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / flilib.zip / FLISRC.ZIP / COMPFRAM.C < prev    next >
C/C++ Source or Header  |  1989-11-17  |  2KB  |  76 lines

  1.  
  2. #include "aai86.h"
  3. #include "aaflisav.h"
  4. #include "aafii.h"
  5.  
  6. #define FLI_EMPTY_DCOMP 8  /* Size returned by fii functions 
  7.                             to indicate no change */
  8.  
  9. static Cbuf *
  10. full_cmap(Cbuf *cbuf, Cmap *cmap)
  11. {
  12. *cbuf++ = 1;
  13. *cbuf++ = 0;
  14. *cbuf++ = 0;
  15. *cbuf++ = 0;
  16. i86_bcopy(cmap, cbuf, AA_COLORS*3);
  17. return(i86_norm_ptr(cbuf+AA_COLORS*3));
  18. }
  19.  
  20. long fli_comp_frame(
  21.     Cbuf *comp_buf, /* Buffer - should be FLI_CBUF_SIZE or bigger */
  22.     Pixel *last_screen, Cmap *last_cmap,     /* Data from previous frame */
  23.     Pixel *this_screen, Cmap *this_cmap,    /* Data for this frame */
  24.     int type)                    /* FLI_BRUN?  FLI_LCCOMP? */    
  25. {
  26. Cbuf *c;
  27. struct fli_frame *frame;
  28. struct fli_chunk *chunk;
  29.  
  30.  
  31. frame = (struct fli_frame *)comp_buf;
  32. i86_wzero(frame, sizeof(*frame)/sizeof(SHORT) );
  33. chunk = (struct fli_chunk *)(frame+1);
  34. /* 1st make the color map chunk */
  35. if (type == FLI_BRUN)
  36.     c = full_cmap((char *)(chunk+1), this_cmap);
  37. else
  38.     c = fii_fccomp(last_cmap, this_cmap, (USHORT *)(chunk+1), AA_COLORS);
  39. chunk->type = FLI_COLOR;
  40. chunk->size = i86_ptr_to_long(c) - i86_ptr_to_long(chunk);
  41. if (chunk->size == FLI_EMPTY_DCOMP)
  42.     c = (char *)chunk;
  43. else
  44.     frame->chunks = 1;
  45. chunk = (struct fli_chunk *)c;
  46. switch (type)
  47.     {
  48.     case FLI_LC:
  49.         c = fii_lccomp(last_screen, this_screen, (USHORT *)(chunk+1), 320, 200);
  50.         break;
  51.     case FLI_BRUN:
  52.         c = fii_brun(this_screen, this_screen, (USHORT *)(chunk+1), 320,200);
  53.         break;
  54.     }
  55. if (c == NULL)
  56.     {
  57.     chunk->size = 64000L+sizeof(chunk);
  58.     chunk->type = FLI_COPY;
  59.     c = i86_norm_ptr((char *)(chunk+1)+64000L);
  60.     i86_wcopy(this_screen, chunk+1, 32000);
  61.     }
  62. else
  63.     {
  64.     chunk->type = type;
  65.     chunk->size = i86_ptr_to_long(c) - i86_ptr_to_long(chunk);
  66.     }
  67. if (chunk->size == FLI_EMPTY_DCOMP)
  68.     c = (char *)chunk;
  69. else
  70.     frame->chunks++;
  71. frame->type = FLIF_MAGIC;
  72. frame->size = i86_ptr_to_long(c) - i86_ptr_to_long(comp_buf);
  73. return(frame->size);
  74. }
  75.  
  76.